from common.base import Base, By,get_driver
import time

class AdminLoginPage(Base):
    adminloginpage_url = 'http://localhost:8080/ecshop/admin/privilege.php?act=login'
    def login(self):
        """
        封装登录后台页面的方法
        :return:self.driver
        """
        self.click((By.XPATH,'//*[@id="panelCloud"]/div[1]/span'))
        self.click((By.ID,'cloudLogin'))
        self.send_keys((By.XPATH,'//*[@id="loginPanel"]/div[1]/input'),'root1234')
        self.send_keys((By.XPATH,'//*[@id="loginPanel"]/div[2]/input'),'root1234')
        self.click((By.XPATH,'//*[@id="loginPanel"]/div[3]/input'))
        time.sleep(2)

    def menber_management_click(self):
        """
        封装打开会员列表的方法
        :return:
        """
        self.switch_to_frame((By.ID,'menu-frame'))
        self.click((By.XPATH,'//*[@id="menu-ul"]/li[8]'))
        self.switch_to_default_frame()

    def delete_menber(self):
        """
        封装删除会员的方法
        :return:
        """
        self.switch_to_frame((By.ID,'main-frame'))
        self.click((By.XPATH,'//*[@id="listDiv"]/table/tbody/tr[3]/td[10]/a[5]'))
        self.alert_accept()

    def page_quit(self):
        self.quit()

if __name__ == '__main__':
    driver = get_driver()
    alp = AdminLoginPage(driver)
    alp.get(AdminLoginPage.adminloginpage_url)
    alp.login()
    alp.menber_management_click()